﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class CameraCtrl : EventTrigger {

    public float XSensitivity = 2f;
    public float YSensitivity = 2f;

    //
    // 摘要:
    //     ///
    //     Called by the EventSystem every time the pointer is moved during dragging.
    //     ///
    //
    // 参数:
    //   eventData:
    //     Current event data.
    public override void OnDrag(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Right)
        {
            float yRot = Input.GetAxis("Mouse X") * XSensitivity;
            float xRot = Input.GetAxis("Mouse Y") * YSensitivity;
            Camera.main.transform.rotation *= Quaternion.AngleAxis(yRot, Camera.main.transform.InverseTransformDirection(Vector3.up))* Quaternion.Euler(-xRot, 0, 0f);
        }
    }

}
